import pymongo


def getClient():
    myClient = pymongo.MongoClient("mongodb://localhost:27017/")
    return myClient


def delete(client):
    myDb = client["w3cschooldb"]
    myCol = myDb["sites"]
    myquery = {"name": {"$regex": "^F"}}
    x = myCol.delete_many(myquery)
    print(x.deleted_count, "个文档已删除")


if __name__ == "__main__":
    client = getClient()
    delete(client)
